﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace KTool2.Exceptions
{
    class ApplicationSettingException : Exception
    {
        private int errorCode;
        private string description;

        public string Description
        {
            get { return description; }
            set { description = value; }
        }

        public int ErrorCode
        {
            get { return errorCode; }
            set { errorCode = value; }
        }

        public ApplicationSettingException(string message) : base(message) { }

        public ApplicationSettingException(int errorCode, object infoObj)
        {
            this.errorCode = errorCode;
            StringBuilder descriptionBuilder = new StringBuilder();

            switch (errorCode)
            { 
                case 1:
                    descriptionBuilder.Append("Error while loading previous settings. Maybe setting file is corrupted.");
                    break;
                default:
                    descriptionBuilder.Append("Application setting: Unexpected error!");
                    if (infoObj != null)
                    {
                        descriptionBuilder.Append("\n").Append(infoObj.ToString());
                    }
                    break;
            }

            this.description = descriptionBuilder.ToString();
        }
    }
}
